#include <stdio.h>
#include <malloc.h>
#include <stdlib.h>

void main()
{
    char *s;
    int n;
    s = (char *)malloc(50 * sizeof(int));
    printf("please input some char: ");
    scanf("%s", s);
    for (n = 0; *s != '\0'; ++s)
        ++n;
    // 释放内存的语句“free（p）；”中的参数p，必须是申请到的动态内存的首地址。
    s = s - n;
    free(s);
    printf("%d\n", n);

    system("pause");
}